﻿using System;

namespace Graphe.Collations.Commands
{
    public class EditSacrumCommand : Command
    {
        #region Constructor

        /// <summary>
        /// Constructor for initializing the command.
        /// </summary>
        /// <param name="sacrum">The sacrum to be edited.</param>
        public EditSacrumCommand(Sacrum sacrum, string text, string representation)
        {
            _sacrum = sacrum;
            _text = text;
            _representation = representation;
        }

        #endregion
        #region Private Instance Fields

        private Sacrum _sacrum;
        private string _text;
        private string _representation;
        private string _oldText;
        private string _oldRepresentation;

        #endregion

        public override void Execute()
        {
            _oldText = _sacrum.Text;
            _oldRepresentation = _sacrum.Representation;

            _sacrum.Text = _text;
            _sacrum.Representation = _representation;
        }

        public override void Undo()
        {
            _sacrum.Text = _oldText;
            _sacrum.Representation = _oldRepresentation;
        }
    }
}
